float4x4	World;
float4x4	View;
float4x4	Projection;
float4x4	matInverseWorld;
//light stuf 
float4		AmbientLightColor;
float		AmbientIntensity;

float4		diffuseLightDirection;//directional dufus light
float4		diffuseLightColor;
float		diffuseIntensity;

float Shininess;
float SpecularPower;


// *******************************
texture2D NormalMap;
sampler2D NormalMapSampler = sampler_state
{
    Texture = <NormalMap>;
    MinFilter = linear;
    MagFilter = linear;
    MipFilter = linear;
};

texture2D Texture;
sampler2D DiffuseTextureSampler = sampler_state
{
    Texture = <Texture>;
    MinFilter = linear;
    MagFilter = linear;
    MipFilter = linear;
};

texture CelMap;
sampler2D CelMapSampler = sampler_state
{
	Texture	  = <CelMap>;
	MIPFILTER = LINEAR;
	MAGFILTER = LINEAR;
	MINFILTER = LINEAR;
};

// TODO: add effect parameters here.

struct OUT
{
	float4 Pos	: POSITION;
	float2 Tex	: TEXCOORD0;
	float3 L	: TEXCOORD1;
	float3 N	: TEXCOORD2;
};

OUT VertexShaderFunction( float4 Pos: POSITION, float2 Tex : TEXCOORD, float3 N: NORMAL )
{
	OUT Out = (OUT) 0;
	
	float4 worldPosition = mul(Pos, World);
    float4 viewPosition = mul(worldPosition, View);
    Out.Pos  = mul(viewPosition, Projection);

	Out.Tex = Tex;
	Out.L = normalize(diffuseLightDirection);
	Out.N = normalize(mul(matInverseWorld, N));
	
	return Out;
}

float4 PixelShaderFunction(float2 Tex: TEXCOORD0,float3 L: TEXCOORD1, float3 N: TEXCOORD2) : COLOR
{
	// Calculate normal diffuse light but use Tex.x as color in stead.
	float4 Color = tex2D(DiffuseTextureSampler, Tex);	
	float Ai = 0.8f;
	float4 Ac = float4(0.075, 0.075, 0.2, 1.0);
	float Di = 1.0f;
	float4 Dc = float4(1.0, 1.0, 1.0, 1.0);
	
	Tex.y = 0.0f;
	Tex.x = (dot(L, N));
	
	float4 CelColor = tex2D(CelMapSampler, Tex);	
	//return CelColor;
	return (Ai*Ac*Color)+(Color*Di*CelColor);
}

technique Technique1
{
    pass Pass1
    {
        // TODO: set renderstates here.

        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}
